<template>
  <div>
    <a-card :body-style="{ padding: '24px 32px' }" :bordered="false">
      <a-form @submit="submit" :form="form">
        <a-form-item
          :label="$t('tenantName')"
          :labelCol="{ span: 7 }"
          :wrapperCol="{ span: 10 }"
        >
          <a-input
            v-decorator="[
              'tenantName',
              { rules: [{ required: true, message: '租户名称不得为空' }] },
            ]"
            :placeholder="$t('tenantNameInput')"
          />
        </a-form-item>
        <a-form-item
          :label="$t('tenantAlias')"
          :labelCol="{ span: 7 }"
          :wrapperCol="{ span: 10 }"
        >
          <a-input
            v-decorator="[
              'tenantAlias',
              { rules: [{ required: true, message: '租户标识不得为空' }] },
            ]"
            :placeholder="$t('tenantAliasInput')"
          />
        </a-form-item>
      </a-form>
    </a-card>
    <footer-tool-bar>
      <a-button type="primary" @click="submit" :loading="loading">{{
        $t("submit")
      }}</a-button>
    </footer-tool-bar>
  </div>
</template>

<script>
import { saveOrUpdateTenant } from "@/services/tenant";
import FooterToolBar from "@/components/tool/FooterToolBar";

export default {
  name: "BasicForm",
  i18n: require("./i18n"),
  components: { FooterToolBar },
  data() {
    return {
      form: this.$form.createForm(this),
      value: 1,
    };
  },
  mounted() {},
  methods: {
    submit() {
      this.form.validateFields((err, values) => {
        if (!err) {
          saveOrUpdateTenant(values).then((rep) => {
            if (rep.data.success) {
              this.$message.success("新增租户成功");
            } else {
              this.$message.error(rep.data.msg);
            }
          });
        }
      });
    },
  },
  computed: {
    desc() {
      return this.$t("pageDesc");
    },
  },
};
</script>

<style scoped>
</style>
